<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
</head>
<body>
  
    <div class="container">
        <!-- <span>hello</span> -->
    </div>



    <script>
        // 此处可以获取 span ? 
        // var el = document.querySelector("span");
        // console.log(el);// null 获取不到span ,因为<span>hello</span>还没渲染

        // 方式1:
        var container = document.querySelector(".container")
        // var span = document.createElement("span")
        // span.innerText = "hello 1234234";
        // container.appendChild(span)

        // 方式2:
        container.innerHTML = "<span>hello world</span>";
        var el = document.querySelector("span");
        console.log(el);// <span>hello</span> 获取到span ,因为<span>hello</span>已经渲染

        // el.remove();// 删除
        container.innerHTML = "";







    </script>
</body>
</html>